function Cart(obj,callback) {
    this.obj = obj;
    this.widget = null;
    this.create = function () {
        var self = this;
        var cover = this.obj.data('cover');
        var title = this.obj.data('title');
        var productList = this.obj.data('product');
        var cs_num = this.obj.data('cs_num');
        this.widget = $('<div data-role="widget" data-widget="sku_dialog" class="sku_dialog" id="showDiv2" style="display: block;"></div>');
        this.widget.append('<div class="widget_mask"></div>');
        this.widget.append('<div class="widget_wrap2"></div>');
        this.widget.find('.widget_wrap2').append('<div class="sku_header">' +
                                                        '<div class="title_pic">' +
                                                            '<span class="img_wrap"><img src="'+cover+'" alt="'+title+'"></span>' +
                                                        '</div>' +
                                                        '<div class="title_pic_1">' +
                                                            '<p class="mall_pd_title">'+title+'</p>' +
                                                            '<p class="mall_pd_jgx">促销价：￥<span>108</span></p>' +
                                                            '<p class="mall_pd_sl">已售：<span>1</span></p>' +
                                                        '</div>' +
                                                        '<div class="colesd_btn">X</div>' +
                                                    '</div>');
        var spec_arr = [];
        var _default = null;
        for(var i in productList){
            if(productList[i].is_default) _default = productList[i];
            var spec_list = JSON.parse(productList[i].spec_list);
            for(var j in spec_list){
                var spec = JSON.parse(spec_list[j]);
                spec_arr[spec.name] = spec_arr[spec.name] || [];
                if($.inArray(spec.value,spec_arr[spec.name]) == -1)
                    spec_arr[spec.name].push(spec.value);
            }
        }
        if(!_default){
            _default = productList[0];
        }
        self.widget.find('.mall_pd_jgx span').text(moneyReZero(_default.price_new));
        self.widget.find('.mall_pd_sl span').text(cs_num);

        var _default_spec = JSON.parse(_default.spec_list);
        var _default_spec_new = [];
        for(var i in _default_spec){
            _default_spec[i] = JSON.parse(_default_spec[i]);
            _default_spec_new[_default_spec[i].name] = _default_spec[i].value;
        }

        for(var name in spec_arr){
            var sku_contant = $('<div class="sku_contant"></div>');
            sku_contant.append('<div class="sku_contant_tlt">' + name + '：</div>');
            sku_contant.append('<div class="sku_contant_size"><ul></ul></div>');
            for(var i in spec_arr[name]){
                if(spec_arr[name][i] == _default_spec_new[name]){
                    sku_contant.find('ul').append('<li data-name="'+name+'" class="active"><a href=javascript:;>'+spec_arr[name][i]+'</a></li>');
                }else{
                    sku_contant.find('ul').append('<li data-name="'+name+'" ><a href=javascript:;>'+spec_arr[name][i]+'</a></li>');
                }
            }
            sku_contant.find('ul li').bind('click',function () {
                if(!$(this).hasClass('active')){
                    $(this).closest('ul').find('li.active').removeClass('active');
                    $(this).addClass('active');
                    var sel_spec = [];
                    $(this).closest('.widget_wrap2').find('.sku_contant_size ul li.active').each(function () {
                        sel_spec[$(this).data('name')] = $(this).text();
                    });
                    var pid;
                    for(var i in productList){
                        var spec_list = JSON.parse(productList[i].spec_list);
                        pid = 0;
                        var index = 0;
                        for(var j=0;j<spec_list.length;j++){
                            var spec = JSON.parse(spec_list[j]);
                            if(spec.value == sel_spec[spec.name]){
                                index++;
                            }
                        }
                        if(j === index){
                            self.widget.find('.mall_pd_jgx span').text(moneyReZero(productList[i].price_new));
                            //self.widget.find('.mall_pd_sl span').text(productList[i].num);
                            break;
                        }
                    }
                }
            });
            this.widget.find('.widget_wrap2').append(sku_contant);
        }

        this.widget.find('.widget_wrap2').append('<div class="sku_contant">' +
                                                        '<div class="sku_contant_tlt">' +
                                                            '<span class="sku_numbers">数量：</span>' +
                                                        '<div class="sku_contant_number">' +
                                                            '<span class="sku_number_add">+</span>' +
                                                            '<span class="sku_numbers_kk">1</span>' +
                                                            '<span class="sku_number_crect">-</span>' +
                                                        '</div>' +
                                                    '</div></div>');
        this.widget.find('.sku_number_add').click(function () {
            var sku_numbers_kk = $(this).closest('.sku_contant_number').find('.sku_numbers_kk');
            var num = parseInt(sku_numbers_kk.text());
            sku_numbers_kk.text(++num);
        });
        this.widget.find('.sku_number_crect').click(function () {
            var sku_numbers_kk = $(this).closest('.sku_contant_number').find('.sku_numbers_kk');
            var num = parseInt(sku_numbers_kk.text());
            if(num > 1)
                sku_numbers_kk.text(--num);
        });
        this.widget.find('.widget_wrap2').append('<div class="sku_bottom_btn2"><a href="javascript:;">加入购物车</a></div>');
        this.widget.find('.sku_bottom_btn2').bind('click',function () {
            var sel_spec = [];
            $(this).closest('.widget_wrap2').find('.sku_contant_size ul li.active').each(function () {
                sel_spec[$(this).data('name')] = $(this).text();
            });
            var pid;
            for(var i in productList){
                var spec_list = JSON.parse(productList[i].spec_list);
                pid = 0;
                var index = 0;
                for(var j=0;j<spec_list.length;j++){
                    var spec = JSON.parse(spec_list[j]);
                    if(spec.value == sel_spec[spec.name]){
                        index++;
                    }
                }
                if(j === index){
                    product = productList[i];
                    pid = productList[i].pid;
                    break;
                }
            }
            if(pid > 0){
                self.unset();
                var num = parseInt(self.widget.find('.sku_numbers_kk').text());
                callback && callback(pid,num);
            }
        });
        $('body').append(this.widget);

        this.widget.find('.colesd_btn').on('click',function () {
            self.unset();
        });
    }
    this.unset = function () {
        $('#showDiv2').remove();
        delete this;
    }
}